package org.poem.handler.impl;


import org.poem.CommonVO;
import org.poem.IdsVo;
import org.poem.ProviderName;
import org.poem.config.error.ErrMsgConfiguration;
import org.poem.datasource.DataAndParametersVo;
import org.poem.datasource.DataSourceVo;
import org.poem.result.CommonResult;
import org.poem.result.PageableResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
@FeignClient(name = ProviderName.DATA_CENTER, configuration = {ErrMsgConfiguration.class})
public interface CDataSourceServices {

    /**
     * 01-展示数据源管理+分页
     *
     * @param pageSize   分页大小
     * @param pageNumber 页数
     * @return
     */
    @GetMapping(value="/v1/tDataSource/findDataSourceList/{size}/{number}")
    CommonResult<PageableResult<DataSourceVo>> findDataSourceList(@RequestParam("subjectId")Long subjectId, @RequestParam("sourceName")String sourceName, @PathVariable("size") Integer pageSize, @PathVariable("number") Integer pageNumber);


    /**
     * 02-新建数据源
     * @return
     */
    @PostMapping("/v1/tDataSource/addDataSource")
    CommonResult<String> addDataSource(@RequestBody DataAndParametersVo dataSourceVo);

    /**
     * 03-根据数据源id查询数据源详情
     * @param dataSourceId   数据源id
     * @return
     */
    @GetMapping("/v1/tDataSource/getDataSourceVoById/{dataSourceId}")
    CommonResult<DataAndParametersVo> getDataSourceVoById(@PathVariable("dataSourceId") Long dataSourceId);

    /**
     * 04-修改数据源
     * @param dataSourceVo
     * @return
     */
    @PostMapping("/v1/tDataSource/updateDataSource")
    CommonResult<String> updateDataSource(@RequestBody DataAndParametersVo dataSourceVo);

    /**
     * 05-根据数据源id删除数据源
     * @param dataSourceId   数据源id
     * @return
     */
    @PostMapping("/v1/tDataSource/deleteDataSourceById")
    CommonResult<String> deleteDataSourceById(@RequestParam("dataSourceId") Long dataSourceId);

    /**
     * 06-根据数据源id批量删除
     * @param idsVo          数据源id数组
     * @return
     */
    @PostMapping("/v1/tDataSource/deleteDataSource")
    CommonResult<String> deleteDataSource( @RequestBody IdsVo idsVo);

    /**
     * 07-下载模板
     *
     * @return
     */
    @GetMapping(value = "/v1/tDataSource/exportDataSourceTemplate")
    ResponseEntity<byte[]> exportDataSourceTemplate();


    /**
     * 10-数据源测试连接
     * @param dataSourceVo
     * @return
     */
    @PostMapping("/v1/tDataSource/testDataSourceConnect")
    CommonResult<String> testDataSourceConnect(@RequestBody DataAndParametersVo dataSourceVo);

    /**
     * 获取数据源
     * @param subjectId
     * @return
     */
    @GetMapping("/v1/tDataSource/getDatasourceList/{subjectId}")
    CommonResult<List<CommonVO>> getDatasourceList(@PathVariable("subjectId") Long subjectId);

    /**
     * 数据管理
     * @param dataSourceVo
     * @return
     */
    @PostMapping("/v1/tDataSource/getSchema")
    CommonResult<List<String>> getSchema(@RequestBody DataAndParametersVo dataSourceVo);


    /**
     * 获取数据源
     * @param subjectId
     * @param datasourceTypeId
     * @return
     */
    @GetMapping("/v1/tDataSource/getDatasourceList/{subjectId}/{datasourceTypeId}")
    CommonResult<List<CommonVO>> getDatasourceList(@PathVariable("subjectId") Long subjectId,@PathVariable("datasourceTypeId") Long datasourceTypeId);

}
